package com.springboot.springbootlogindemo.controller;


import com.springboot.springbootlogindemo.domain.MusicCollection;
import com.springboot.springbootlogindemo.service.MusicCollectionService;
import com.springboot.springbootlogindemo.utils.Result;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController//表明此类是一个控制器类,且返回的不是视图，而是数据
@RequestMapping("/musicCollection")//控制器类的基路由
public class MusicCollectionController {
    @Resource
    private MusicCollectionService musicCollectionService;


    /**
     * 向歌单添加歌曲
     * @param songId
     * @param songListId
     * @return
     */
    @PostMapping("/addSong")
    public Result  addSong(@RequestParam Long songId, @RequestParam Long songListId){
        return musicCollectionService.addSong(songId,songListId);
    }

    /**
     * 从歌单删除歌曲
     * @param songId
     * @param songListId
     * @return
     */
    @PostMapping("/delete")
    public Result  deleteSong(@RequestParam Long songId, @RequestParam Long songListId){
        return musicCollectionService.deleteSong(songId,songListId);
    }


    /**
     * 获取歌单所有歌曲
     * @param songListId
     * @return
     */
    @GetMapping("/showSongs")
    public Result showSongs(@RequestParam Long songListId){
        return musicCollectionService.showSongs(songListId);
    }


}
